<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>DataGrid Complex Toolbar - jQuery EasyUI Demo</title>
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Resourse/js/jquery.cookie.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/themes/default/easyui.css" id="easyuiTheme">
	<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Resourse/js/changeEasyuiTheme.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/themes/icon.css">
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery.easyui.min.js"></script>
	<style type="text/css">  
        #studentfm{  
            margin:0;  
            padding:10px 10px 30px 5px;  
       }  
       .ftitle{  
            font-size:14px;  
            font-weight:bold;  
            padding:5px 0;  
            margin-bottom:10px;  
            border-bottom:1px solid #ccc;  
        }  
       .fitem{  
            margin-bottom:5px;  
       }  
        .fitem label{  
           display:inline-block;  
            width:80px;  
        }
        .formText {
        	width : 200px;
        }  
    </style>  
    <script type="text/javascript">  
      var url;  
      function newUser(){  
            $('#dlg').dialog('open').dialog('setTitle','新增学生信息');  
           	$('#studentfm').form('clear');  
            url = '__URL__/add/';  
       }  
        
       function editUser(){  
    	   var rows = $('#stu_list_data').datagrid('getSelections'); 
            if (rows.length == 1){  
               $('#dlg').dialog('open').dialog('setTitle','修改学生信息');  
               $('#studentfm').form('load',rows[0]);  
               url = '__URL__/save?id=' + rows[0].Id;  
           }  
       }
       
       //根据条件查找
       function searchStu() {
    	   var xx_search = $("#XS_XX_SEARCH").combobox('getValue');
    	   if(xx_search == 0){
    		   xx_search = null;
    	   }
    	   var queryParams = $('#stu_list_data').datagrid('options').queryParams; 
    	   queryParams.XS_XM = $("#XS_XM_SEARCH").val();
    	   queryParams.XS_PY = $("#XS_PY_SEARCH").val();
    	   queryParams.XS_XH = $("#XS_XH_SEARCH").val();
    	   queryParams.XS_XX = xx_search;   
    	   
    	   $('#stu_list_data').datagrid('options').queryParams = queryParams; 
    	   $('#stu_list_data').datagrid('reload'); 
       }
     	
       //保存
       function saveUser(){
           $('#studentfm').form('submit',{  
                url: url,  
                onSubmit: function(){  
                   return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');  
                    if (result.errorMsg){  
                       $.messager.show({  
                           title: '错误',  
                           msg: result.errorMsg  
                        });  
                    } else {  
                        $('#dlg').dialog('close');      // close the dialog  
                        $('#stu_list_data').datagrid('reload');    // reload the user data  
                    }  
                }  
            });  
        }  
       
       //删除学生
        function destroyUser(){  
           var rows = $('#stu_list_data').datagrid('getSelections');  
           var ids = '';
           for(var i=0;i<rows.length;i++){
        	   ids += rows[i].Id + ',';
           }
           ids = ids.substring(0, ids.length-1);//获取所有要删除的ID
            if (rows.length!=0){  
            	$.messager.defaults.ok = "确定"; //改变默认按钮文字
            	$.messager.defaults.cancel = "取消"; //改变默认按钮文字
                $.messager.confirm('确认','确认要删除吗?',function(r){             	
                   if (r){              	   
                      $.post('__URL__/del/',{id:ids},function(result){  
                            if (result.success){  
                               $('#stu_list_data').datagrid('reload');    // reload the user data  
                            } else {  
                               $.messager.show({   // show error message  
                                    title: '错误',  
                                    msg: result.errorMsg  
                                });  
                           }  
                       },'json');  
                    }  
                });  
            }  
       }  
        
       $(window).resize(function(){  
        	$('#tt').datagrid('resize');  
       });   
       
       //设置分页
       $(function(){
    	 	//设置分页控件  
           var p = $('#stu_list_data').datagrid('getPager');  
           $(p).pagination({  
               pageSize: 10,//每页显示的记录条数，默认为10  
               pageList: [1,10,20,30],//可以设置每页记录条数的列表  
               beforePageText: '第',//页数文本框前显示的汉字  
               afterPageText: '页    共 {pages} 页',  
               displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
           }); 
       });
       
    </script>  
</head>
<body style="overflow: hidden; height:auto;margin:0">
	<table id ="stu_list_data" class="easyui-datagrid" style="overflow: hidden;height:auto;margin:0"
			data-options="title:'学生信息列表',border:true,striped:true,nowrap:false,fit:true,rownumbers:true,pagination:true,singleSelect:false,url:'__URL__/read/',toolbar:'#tb'" >
		<thead>
			<tr>
				<th data-options="field:'checkbox',checkbox:true" id="checkedAll"></th>	
				<th data-options="field:'Id',fitColumns: true,hidden:true">ID</th>
				<th data-options="field:'XS_XH',fitColumns: true,width:140,align:'center'">学号</th>
				<th data-options="field:'XS_XM',fitColumns: true,width:80,align:'center'">姓名</th>
				<th data-options="field:'XS_PY',fitColumns: true,width:80,align:'center'">拼音</th>
				<th data-options="field:'XS_XB',fitColumns: true,width:80,align:'center',formatter:function(value,rowData,rowIndex){ if(value == '1'){ return '男'} else if(value =='0') { return '女'} else { return '保密'}}">性别</th>
				<th data-options="field:'XS_CSRQ',itColumns: true,width:120,align:'center'">出生日期</th>
				<th data-options="field:'XS_RXRQ',itColumns: true,width:120,align:'center'">入学日期</th>
				<th data-options="field:'XS_XX',itColumns: true,width:160,align:'center'">就读学校</th>
				<th data-options="field:'XS_NJ',itColumns: true,width:80,align:'center'">年级</th>
				<th data-options="field:'XS_BJ',itColumns: true,width:80,align:'center'">班级</th>
				<th data-options="field:'XS_JZXM',itColumns: true,width:80,align:'center'">家长姓名</th>
				<th data-options="field:'XS_JZDH',itColumns: true,width:80,align:'center'">家长电话</th>
				<th data-options="field:'XS_JTZZ',itColumns: true,width:200,align:'center'">家庭住址</th>
				<th data-options="field:'XS_ZT',itColumns: true,width:80,align:'center',formatter:function(value,rowData,rowIndex){ if(value == '1'){ return '活跃'} else { return '冻结'}}">状态</th>
			</tr>
		</thead>
	</table>
	<div id="tb" style="padding:5px;height:auto">
		<div>
			<form id="stu_search_form" method="post" novalidate> 
			学校:<input name="XS_XX_SEARCH" id="XS_XX_SEARCH" class="easyui-combobox formText" style="width:100px" data-options="valueField:'id',textField:'text',url:'__URL__/schoolList/'" >			
			班级:<input name="XS_BJ_SEARCH" id="XS_BJ_SEARCH" class="easyui-validatebox" style="width:100px" >
 	  		购买金额:<input name="XS_PY_SEARCH" id="XS_PY_SEARCH" class="easyui-validatebox" style="width:100px" >&nbsp;&nbsp;-&nbsp;&nbsp;<input name="XS_PY_SEARCH" id="XS_PY_SEARCH" class="easyui-validatebox" style="width:100px" >
			日期: <input class="easyui-datebox" style="width:100px">
			&nbsp;&nbsp;-&nbsp;&nbsp;<input class="easyui-datebox" style="width:100px">
			状态:<input name="XS_XX_SEARCH" id="XS_XX_SEARCH" class="easyui-combobox formText" style="width:100px" data-options="valueField:'id',textField:'text',url:'__URL__/orderStatus/'" >						
			<a href="javascript:searchStu()" class="easyui-linkbutton" iconCls="icon-search">查询</a>
			</form>
		</div>
	</div>
	<div id="dlg" class="easyui-dialog" style="width:550px;height:680px;padding:10px 20px"  
            closed="true" buttons="#dlg-buttons">  
        <div class="ftitle">学生基本信息</div>  
        <form id="studentfm" method="post" novalidate>  
            <!--  <div class="fitem">  
                <label>学&nbsp;&nbsp;&nbsp;&nbsp;号:</label>  
               <input name="XS_XH" class="easyui-validatebox formText" required>  
            </div>          -->
            <div class="fitem">  
                <label>姓&nbsp;&nbsp;&nbsp;&nbsp;名:</label>  
               <input name="XS_XM" class="easyui-validatebox formText"  required="true"  missingMessage="不能为空">  
            </div>  
            <div class="fitem">  
                <label>姓名拼音:</label>  
                <input name="XS_PY" class="easyui-validatebox formText" >  
            </div>  
            <div class="fitem">  
                <label>性&nbsp;&nbsp;&nbsp;&nbsp;别:</label>  
                <INPUT type="radio" name="XS_XB" checked="checked" value="1">男
				<INPUT type="radio" name="XS_XB" value="0">女
           </div>  
           <div class="fitem">  
                <label>出生日期:</label>  
				<input name="XS_CSRQ" class="easyui-datebox formText"></input>
           </div>  
           <div class="fitem">  
                <label>入学日期:</label>  
				<input name="XS_RXRQ" class="easyui-datebox formText" id="XS_RXRQ" required="true"  missingMessage="不能为空"></input>
           </div>
           <div class="fitem">  
                <label>就读学校:</label>  
				<input class="easyui-combobox formText" id="schoolList" name="XS_XX" 
						data-options="valueField:'id',textField:'text',url:'__URL__/schoolList/'">
           </div>
           <div class="fitem">  
                <label>就读年级:</label>  
				<input name="XS_NJ" class="easyui-validatebox formText" > 
           </div>
           <div class="fitem">  
                <label>就读班级:</label>  
				<input name="XS_BJ" class="easyui-validatebox formText" required="true"  missingMessage="不能为空"> 
           </div>
           <div class="fitem">  
                <label>家长姓名:</label>  
				<input name="XS_JZXM" class="easyui-validatebox formText" required="true"  missingMessage="不能为空"> 
           </div>   
           <div class="fitem">  
                <label>家庭住址:</label>  
				<input name="XS_JTZZ" class="easyui-validatebox formText" required="true"  missingMessage="不能为空"> 
           </div>
           <div class="fitem">  
                <label>家庭电话:</label>  
				<input name="XS_JTDH" class="easyui-validatebox formText" required="true"  missingMessage="不能为空"> 
           </div>   
           <div class="fitem">  
                <label>家长电话:</label>  
				<input name="XS_JZDH" class="easyui-validatebox formText" required="true"  missingMessage="不能为空"> 
           </div>              
            <div class="fitem">  
                <label>家长Email:</label>  
                <input name="XS_JZMAIL" class="easyui-validatebox formText" validType="email">  
            </div>
            <div class="fitem">
                <label>学校负责人:</label>  
				<input class="easyui-combobox formText" id="XS_FZR" name="XS_FZR"
						data-options="valueField:'id',textField:'text'">
           </div> 
            <div class="fitem">
                <label>推荐人:</label>  
				<input class="easyui-validatebox formText"  name="XS_TJR">
           </div> 
           <div class="fitem">
                <label>备注:</label>
                <textarea name="XS_BZ" style="height:60px;width:200px"></textarea>
            </div>  
            <input name="XS_ZT" class="easyui-validatebox formText" type="hidden">         
        </form>  
    </div>  
    <div id="dlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">保存</a>  
       <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>  
    </div>  
</body>
</html>